<script type="text/javascript">
	$(function() {
	    //投资次数
        $(".borrowSetting input").on('click',function(){
            if($("#specal2").attr("checked")=="checked"){
                $('#investmentNum').attr("disabled",false);
            }else if($("#specal3").attr("checked")=="checked"){
            	if($('#changetoDay').attr("checked")!="checked") {
                	$('#changetoDay').trigger("click");
                		
                	}
				$('#changetoDay').attr("checked","checked");
			}else {
                $('#investmentNum').attr("disabled",true);
            }
        })
	    
	    $.fn.dataGridOptions.addBorrowFormSubFun("#form",'/modules/loan/borrow/addBorrow.html');
	    var $award = $("select[name='award']"), $part_account = $("#part_account");
		$award.change(function() {
			if ($(this).val() == 0) {
				$part_account.prop("disabled", true);
				$part_account.val('');
				$part_account.attr("data-options","");
				$part_account.removeClass("validatebox-invalid");
				$.parser.parse($(".borrowForm")); 
			} else {
				$part_account.prop("disabled", false);
				$part_account.attr("data-options","validType:'rewardRatio[0.1,6]',required: true");
				$.parser.parse($(".borrowForm")); 
			}
		});
	    $("#isDXB").click(function(){
	    	if($('#isDXB').attr("checked"))
			{	
		        $('#pwd').attr("disabled",false);
		    	$('#pwd').attr("data-options","required: true");
		     	$.parser.parse($(".borrowForm"));
		    }else{
		        $('#pwd').attr("disabled",true);
		        $('#pwd').val("");
		        $('#pwd').attr("data-options","");
		        $('#pwd').removeClass("validatebox-invalid");	// 当输入框内填写非法时，取消定向密码，应删除提示非法的类名
		        $.parser.parse($(".borrowForm"));
		    }
	    });
	    $("#vouch").click(function(){
	    	$("#vouchFirms").toggle();
	    });
	    $('#changetoDay').click(function(){
			if(!$('#borrow_day').is(":animated")){
				var dayManageFee = ${dayManageFee};
				var manageFee= ${manageFee};
				
				var borrowTimeType=$('#borrowTimeType').val();
				if(borrowTimeType==0){
					$(this).addClass("dayhover")
					$('#borrowTimeType').val('1');
					$('#time_limit_day_box').html('<@linkage name="timeLimit" id="time_limit_day" class="select_low"  type="value" nid="borrow_time_limit_day"/>');
					$('#time_limit_day').addClass("J_input")
					$('#time_limit_box').html('')
					$('#style').html('<option value="2">一次性还款</option>');
					$('#changetoDay').html('按月');
				}else if($("#typeId").val()!=101){
					$(this).removeClass("dayhover")
					$('#borrowTimeType').val('0');
					$('#time_limit_day_box').html('')
					$('#time_limit_box').html('<@linkage name="timeLimit" id="time_limit" class="J_input select_low" type="value" nid="borrow_time_limit"/>')
					$('#time_limit').addClass("J_input");
					$('#time_limit').show();
					$('#style').html('<option value="1">等额本息</option><option value="2">一次性还款</option><option value="3">每月还息到期还本</option>');
					$('#changetoDay').html('按天');
				}
				borrowTimeType=$('#borrowTimeType').val();
			}
	    });

		$('#recommend').click(function(){
				$('#isRecommend').val('1');
				var isRecommend=$('#isRecommend').val();
				isRecommend=$('#isRecommend').val();
		});
	    
	    //	输入框要求必须为整数数字
		$('.int_figure_required').bind('keyup blur', function() {
	        // 不能输入 类似00、01、0000001的数值
	  	  	if($(this).val().match(/^0+\d+/)){
	            this.value = $(this).val().replace(/^0+(\d+)/, '$1');
	        }
	  	  	
		});
	});
</script>
<form id="form" method="post" enctype="multipart/form-data">
<div class="borrowForm" style="border-top:none;">
	<input type="hidden" name="type" value="${typeId}" id="typeId">
	<input type="hidden" id="dayManageFee" value="${dayManageFee}"/>
	<input type="hidden" id="manageFee" value="${manageFee}"/>
	<#if typeId!="101"&&typeId!="103">
		<h1 class="borrowFormTitle">【标设置】</h1>
	    <div class="borrowSetting">
	        <input type="radio" class="radio" id="specal1" name="category" value="1" checked>
	        <label for="specal1">普通标</label>
	        <input type="radio" id="specal2" name="category" value="0">
	        <label for="specal2">新手专享</label>
            <input type="radio" id="specal3" name="category" value="2">
            <label for="specal3">体验标</label>
	    </div>

	 <#else>
	    <input name="category" type="hidden" value="1"/>
	 </#if>
	<h1 class="borrowFormTitle">基本信息</h1>
	<ul>
		<li><span>借款标题：</span><input type="text" name="name" autocomplete="off" maxlength="25" class="borrowFormTxt easyui-validatebox" data-options="required: true,validType:'maxLength[25]'" /></li>
		<li><span>借款人手机：</span><input type="text" name="mobile" id="email" autocomplete="off" size="15" class="borrowFormTxt2 easyui-validatebox" data-options="required: true,validType:'mobile'" /><input type="button" value="选择" onclick="showMobile()" class="selectEmail" /></li>
		<#if typeId!="101">
		<li><span>开标时间</span><input type="text" name="putStartTime" id="startTime" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:true})" data-options="required: true" class="searchTime"/></li>
         </#if>
		<li><span>借款总金额：</span><input type="text" name="account" autocomplete="off" onkeyup="value=value.replace(/[^0-9]/g,'')" size="15" class="borrowFormTxt1 easyui-validatebox int_figure_required" data-options="required: true,validType:'accout[500,5000000]'"><em>元</em></li>
		<li><span>借款年利率：</span><input type="text" name="apr" autocomplete="off" size="15" class="borrowFormTxt1 easyui-validatebox int_figure_required"  style="width:60px" onkeyup="value=value.replace(/[^0-9.]/g,'')" maxlength="5" data-options="required: true,validType:'apr[0,24]'"><em>%</em></li>
		
		<li><span>借款用途：</span><@linkage name="borrowUse" id="use" class="borrowFormTxt J_input" type="value" nid="borrow_use" /></li>
		<li><span>是否天标：</span><input type="checkbox" id="changetoDay" class="day_chose" ></li>
		<li><span>借款期限：</span>
			<#if typeId=="101">
	        <input type="text" class="borrowFormTxt easyui-validatebox J_input" value="满标即还" readonly="readonly" />
	        <#else>
	        <label id="time_limit_box"><@linkage name="timeLimit" id="time_limit" class="J_input select_low" type="value" nid="borrow_time_limit"/></label>
	        <label id="time_limit_day_box"></label>
	        </#if>
		</li>
		<li id="borrow_day" style="display:none;">
			<span>是否天标：</span><input type="hidden" name="borrowTimeType" id="borrowTimeType" value="0" />
			<input type="checkbox" checked="checked" disabled="disabled">
		</li>
		<li>
			<span>还款方式：</span>
			<#if typeId=="101">
			<select name="style" id="style" class="borrowFormTxt">
				<option value="2">一次性还款</option>
			</select>
			<#else>
	        <@linkage name="style" id="style" nid="borrow_style" type="value" class="J_input" />
	        </#if>
		</li>
		<li>
   			<span>奖励方式：</span>
   			<select name="award">
   				<option value="0" selected=selected>没有奖励</option>
   				<option value="1">比例奖励</option>
   			</select>
     	</li>
		<li><span>投标奖励比例：</span><input type="text" id="part_account" name="partAccount"  onkeyup="value=value.replace(/[^0-9.]/g,'')" maxlength="5" autocomplete="off" class="borrowFormTxt1 easyui-validatebox int_figure_required" size="15" data-options="validType:'rewardRatio[0.1,6]'" disabled="disabled"><em>%</em></li>
		<li><span>是否是定向标：</span><input id="isDXB" type="checkbox" name="isDXB" value="1" size="15" class="easyui-validatebox"></li>
		<li><span>定向标密码：</span><input type="text" name="pwd" size="15" onKeyUp="value=value.replace(/[^\w\/]/ig,'')" class="borrowFormTxt easyui-validatebox" id="pwd" disabled="disabled" maxlength="6"> </li>
		<#if typeId!="110"&&typeId!="117">
			<li><span>最低投标金额：</span><@linkage name="lowestAccount" class="borrowFormTxt J_input" id="lowest_account" nid="borrow_lowest_account" type="value" /></li>
			<li class="add-li"><span style="width: 126px;">最高累积投标总额：</span><@linkage name="mostAccount" class="borrowFormTxt J_input" id="most_account" nid="borrow_most_account" type="value" /><input type="hidden" id="typeStr" name="typeStr" /></li>
		</#if>
		<#if typeId=="117">
			<li><span>最低投标金额：</span><input type="text" name="lowestAccount" autocomplete="off" onkeyup="value=value.replace(/[^0-9]/g,'')" size="15" class="borrowFormTxt1 easyui-validatebox int_figure_required" data-options="required: true,validType:'accout[0,10000]'"><em>元</em></li>
			<li class="add-li"><span style="width: 126px;">最高累积投标总额：</span><@linkage name="mostAccount" class="borrowFormTxt J_input" id="most_account" nid="borrow_most_account" type="value" /><input type="hidden" id="typeStr" name="typeStr" /></li>
		</#if>
		<#if typeId=="110">
		<li><span>每份投标金额：</span><input type="text" name="flowMoney" class="borrowFormTxt easyui-validatebox" size="15"><em>元</em></li>
		<li><span>单笔最低投标金额：</span><@linkage name="lowestSingleLimit" class="J_input" id="borrowFormTxt lowest_single_limit" nid="borrow_most_account" type="value" /></li>
		<li class="add-li"><span>单笔最多投标总额：</span><@linkage name="mostSingleLimit" class="J_input" id="borrowFormTxt most_single_limit" nid="borrow_most_account" type="value" /></li>
		</#if>
		<li><span>是否是推荐标：</span><input id="isRecommend" type="checkbox" name="isRecommend" value="1" class="easyui-validatebox"></li>
		<input name="borrowAddPageToken" value="${borrowAddPageToken!}" type="hidden"/>
	</ul>
	
	<div class="borrowFormMuti"><span>借款详情：</span>
	
	<#include "../../column/article/umeditor.htm">
	<@showUeditor width=600 heigth=400 id="articleEditor" name="content" content=""/>
	<!-- <textarea id="content" name="content" class="easyui-validatebox borrowFormTextarea" data-options="required: true"></textarea> -->
	</div>
</div>
<div class="borrowForm">
	<h1 class="borrowFormTitle">证明资料图</h1>
    <div id="uploadGuaranteeBox" class="uploadWrap" data-arr="uploadFile">
        <ul id="borrowPagePic" class="photoUpload">
            <li class="addFileBtn">
              <input type="file" name="file" class="uploadFileInput" id="uploadFile" onchange="return ajaxFileUpload1('uploadFile','/imageUp.jsp?editorid=borrow','picPath');" title="点击上传图片" />
            </li>
        </ul>
   </div>	
</div>



<div class="borrowForm">
	<h1 class="borrowFormTitle">借款缩略图</h1>
    <div id="uploadThumbnailBox" class="uploadWrap" data-arr="uploadThumbnailFile">
        <ul id="borrowThumbnailPic" class="photoUpload">
            <li class="addFileBtn">
              <input type="file" name="thumbnailFile" class="uploadFileInput" id="uploadThumbnailFile" onchange="return ajaxFileUpload3('uploadThumbnailFile','/imageUp.jsp?editorid=borrow','thumbnailPicPath');" title="点击上传图片" />
            </li>
        </ul>
   </div>	
</div>

</form>
<script type="text/javascript">seajs.use("${theme_dir}/js/ajaxfileupload");seajs.use("${theme_dir}/js/upload");</script>
<script type="text/javascript">seajs.use("/plugins/layer/layer.min");seajs.use("/plugins/layer/skin/layer.css");</script>

<!-- 图片预览-->
<script type="text/javascript">
	$(".fileshow").fancybox();
	$('.l-btn-text').click(function(){
	  	if($("#borrowPagePic li").length<=1){
		 	 layer.alert('请上传图片资料', 8);
		  	return false;
	  	}

		// 功能 #465 后台发标的时候，缩略图改为不是必输项
		/*
	  	if($("#borrowThumbnailPic li").length<=1){
		  	layer.alert('请上传缩略图', 8);
		  	return false;
	  	}
	  	*/
	})
</script>
<script>
  most_account = $("#most_account");
  lowest_account = $("#lowest_account");
  
  most_account.change(function() {
	  most_account_val = parseInt(most_account.find("option:selected").html().replace("元",""));
	  lowest_account_val = parseInt(lowest_account.find("option:selected").html().replace("元",""));
  if(most_account_val<lowest_account_val)
  {
          //构造确认框DOM
          $.layer({
              type: 1,
              closeBtn: [0,true],
              title: "温馨提示",
              area: ['460px', '194px'],
              border: [1, 1, '#cecfd0'],
              page: {
                  html: '<div class="tipsWrap" style="padding-left:100px;padding-top:50px;">最高投标金额不能小于最低投标金额。</div>'
              },
            close:function(){
            	$("#most_account").addClass("validatebox-invalid");
            }
          }); 
  }
  else{
	  $("#most_account").removeClass("validatebox-invalid");
  }
  })
  
  lowest_account.change(function() {
	  most_account_val = parseInt(most_account.find("option:selected").html().replace("元",""));
	  lowest_account_val = parseInt(lowest_account.find("option:selected").html().replace("元",""));
  if(most_account_val<lowest_account_val)
  {
          //构造确认框DOM
          $.layer({
              type: 1,
              closeBtn: [0,true],
              title: "温馨提示",
              area: ['460px', '194px'],
              border: [1, 1, '#cecfd0'],
              page: {
                  html: '<div class="tipsWrap" style="padding-left:100px;padding-top:50px;">最高投标金额不能小于最低投标金额。</div>'
              },
            close:function(){
            	$("#most_account").addClass("validatebox-invalid");
            }
          });
  }
  else{
	  $("#most_account").removeClass("validatebox-invalid");
  }
  })
</script>
